package rack.lite.view

import rack.lite.view.Console as con
import rack.lite.model.DisciplinaDao
import rack.lite.controller.DisciplinaBo

/**
 *
 * @author atila
 */
@Singleton class DisciplinaView {

   def menu() {
      def builder = new StringBuilder()
      builder.append("[c]riar Disciplina\n")
      builder.append("[_*][l]istar Disciplinas\n")
      builder.append("[d]eletar Disciplina\n")
      builder.append("[/sair][/quit][/exit][/clear]")
      println builder.toString()
   }

   def index() {
      def option
      while (true) {
         menu()
         print con.bash
         option = con.read.nextLine()
         switch (option) {
            case ["c", "C"]:
               DisciplinaBo.instance.create()
               continue
            case ["", "*", "l", "L"]:
               DisciplinaDao.instance.list()
               continue
            case ["d", "D"]:
               DisciplinaBo.instance.delete()
               continue
            case ["/sair", "/quit", "/exit"]:
               return false
            case "/clear":
               con.clearConsole()
               continue
            default:
               println "Opção inválida."
               continue
         }
      }
   }
}

